home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Complementary Applications 2004 May / SGI IRIX 6.5 Complementary Applications 2004 May.iso / dist / OpenOffice.idb / usr / OpenOffice / help / en / sbasic.jar / text / sbasic / common / 03090203.xml < prev    next >
Encoding:
Extensible Markup Language  |  2002-01-24  |  3.0 KB  |  34 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <html><head><title>While...Wend Statement[Runtime]</title><meta name="filename" content="text/sbasic/common/03090203"/><meta name="language" content="en-US"/><help:css-file-link xmlns:help="http://openoffice.org/2000/help"/><!--The CSS style header method for setting styles--><style type="text/css">
  3.  
  4.         p.P1{
  5.                 }
  6.         p.P2{
  7.                 }
  8.         span.T1{
  9.                 font-weight:bold;}
  10.         </style></head><body>
  11.   
  12.   
  13.   <help:to-be-embedded Eid="whilewend" xmlns:help="http://openoffice.org/2000/help">
  14.   <p class="Head1"><help:link Id="66562">While...Wend Statement[Runtime]</help:link></p>
  15.   <p class="Paragraph">If the program encounters a While statement, it tests the condition. If the condition is False, the program continues directly following the Wend statement. If the condition is True, the loop is executed until the program finds Wend and then jumps back to the <span style="font-weight:bold;"><text:s text:c="" xmlns:text="http://openoffice.org/2000/text"/>While </span><text:s text:c="" xmlns:text="http://openoffice.org/2000/text"/>statement. If the condition is still True, the loop will be executed again; otherwise the program continues with the statement following the <span style="font-weight:bold;"><text:s text:c="" xmlns:text="http://openoffice.org/2000/text"/>Wend </span><text:s text:c="" xmlns:text="http://openoffice.org/2000/text"/>statement.</p>
  16.   </help:to-be-embedded>
  17.   <p class="Paragraph">Opposed to <help:link Id="66463" Eid="doloop" xmlns:help="http://openoffice.org/2000/help">Do...Loop</help:link>, a <span class="T1"><text:s text:c="" xmlns:text="http://openoffice.org/2000/text"/>While...Wend</span> loop cannot be canceled with <help:link Id="66590" Eid="exit" xmlns:help="http://openoffice.org/2000/help">Exit</help:link>. You should never exit a <span class="T1">While...Wend</span> loop with <help:link Id="66534" Eid="goto" xmlns:help="http://openoffice.org/2000/help">GoTo</help:link>, since this can cause a runtime error.</p>
  18.   <p class="Paragraph">Use of <span class="T1">Do...Loop</span> is more flexible and is therefore recommended.</p>
  19.   <p class="Paragraph"><span class="T1">Syntax</span>:</p>
  20.   <p class="Paragraph">While Condition [Statement] Wend <help:key-word value="While" tag="kw66562_1" xmlns:help="http://openoffice.org/2000/help"/></p>
  21.   <p class="P2">Example:</p>
  22.   <p class="PropText">Sub ExampleWhileWend</p>
  23.   <p class="PropText">Dim stext As String</p>
  24.   <p class="PropText">Dim iRun As Integer</p>
  25.   <p class="PropText">sText ="This is a short text"</p>
  26.   <p class="PropText">iRun = 1</p>
  27.   <p class="PropText">while iRun < Len(sText)</p>
  28.   <p class="PropText"><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>if Mid(sText,iRun,1 )<> " " then Mid( sText ,iRun, 1, Chr( 1 + Asc( Mid(sText,iRun,1 )) )</p>
  29.   <p class="PropText"><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>iRun = iRun + 1</p>
  30.   <p class="PropText">Wend</p>
  31.   <p class="PropText">MsgBox sText,0,"Text encoded"</p>
  32.   <p class="PropText">end sub</p>
  33.   <p class="PropText"/>
  34.  </body></html>